<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <common-head></common-head>
  </div>
  <script src="./vue.global.js"></script>
  <script src="./axios.js"></script>
  <script>
    const { createApp } = Vue;
    const app = createApp({
    });
    // https://api.it120.cc/conner/
    const CommonHead = {
      template: `
        <div>
          <h2>这是组件1</h2>
          <ul>
           <li v-for="cate in cates" :key="cate.id">
              <img width="100" :key="cate.id" :src="cate.icon"/>
              <h4>{{cate.name}}</h4>
          </li>
          </ul>
        </div>
        
      `,
      data() {
        return {
          cates: [],
          arts: []
        }
      },
      methods: {

        fetchCates() {
          axios.get('https://api.it120.cc/conner/cms/category/list', {
            params: {
              a: 10,
              b: 20
            }
          }).then(res => {
            if (res.data.code === 0) {

              this.cates = res.data.data

            }
          })
        },
        fetchArts() {
          axios.post('https://api.it120.cc/conner/cms/news/list/v2', {
            a: 10,
            b: 100
          }).then(res => {
            console.log(res);
          })
        }
      },
      created() {
        this.fetchCates()
        this.fetchArts()
      }
    }
    app.component('CommonHead', CommonHead)


    app.mount('#app')
  </script>
</body>

</html>